<template>
	<view>
		<Cropper ref="cropper"
		width="100%"
		height="600rpx"
		cutWidth="150px"
		:zoom="1"
		:angle="0"
		:src="src"
		canvasBackground="red"
		@cropped="cropped"
		></Cropper>
		<button class="q-mt-sm" @click="clickUpload">选择图片</button>
	</view>
</template>

<script>
	import Cropper from '@/components/nice-cropper/cropper.vue';
	export default {
		components:{
			Cropper
		},
		data() {
			return {
				src:""
			}
		},
		methods: {
			clickUpload() {
				//this.$refs.uploadImg.click();
				// let that=this;
				uni.chooseImage({
				  count: 1,
				  sizeType: ['original', 'compressed'],
				  sourceType: ['album', 'camera'],
				  success:(res)=>{
				    // tempFilePath可以作为img标签的src属性显示图片
				    const tempFilePaths = res.tempFilePaths;
					console.log(res.tempFilePaths);
					this.src=res.tempFilePaths[0];
					// that.urlTobase64(res.tempFilePaths[0],(data)=>{
					// 	console.log(data);
					// 	that.option.img=data;
					// });
				  }
				})
			},
			cropped(imagePath, imageInfo){
				console.log(imagePath,imageInfo)
			}
		}
	}
</script>

<style>

</style>
